<template>
	<view class="content">
		<view class="cellList" >
			<view class="" @click="goRoute('/packageA/pages/userinfo/userinfo')">
				<p>个人资料</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<view class="" @click="goHtml($store.state.agreementList.user)">
				<p>用户协议</p>
				<image  src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<view class="" @click="goHtml($store.state.agreementList.provacy)">
				<p>隐私政策</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<view class="" @click="goHtml($store.state.agreementList.sdk)">
				<p>权限说明</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<view class="" @click="goRoute('/packageA/pages/set/aboutus/aboutus')">
				<p>关于我们</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<!-- #ifdef APP -->
			<view class="" @click="showoff = true">
				<p>注销账号</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view>
			<!-- #endif -->
			<!-- <view class="" @click="goHtml($store.state.agreementList.authority)">
				<p>SDK目录</p>
				<image src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/rightIcon.png" mode=""></image>
			</view> -->
		</view>
		<!-- #ifdef APP -->
		<view class="buttom" @click="show = true" v-if="!userInfo.guest">退出登录</view>
		<!-- #endif -->
		<u-modal :show="show" title="确定退出？" showCancelButton @cancel="show = false" @confirm="loginOut"></u-modal>
		<u-modal :showConfirmButton="true" :showCancelButton='true' :show="showoff" :content='content'
			@cancel="showoff = false" @confirm="confirm"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				islogin: true,
				version: '',
				show: false,
				showoff: false,
				userInfo: this.$store.state.userInfo,
				cacheSize: '',
				content: '是否确认注销账号'
			}
		},
		onLoad() {
			const that = this
			this.getUserInfo()
			var data = uni.getStorageSync('config')
			uni.getSystemInfo({
				success(res) {
					console.log(res);
					that.version = res.appVersion
				}
			});
		},

		methods: {
			getUserInfo() {
				this.$api.getUserInfo().then(res => {
					this.islogin = res.data.data.guest
				})
			},
			async loginOut() {
				uni.showLoading({
					title: '退出中...'
				})
				this.show = false
				await this.$api.logout().then(async res => {
					console.log(res)
					this.$store.commit('updateUserInfo', {})
					uni.setStorageSync('Token', res.data.data.token)
					// await this.launch()
					uni.hideLoading()
					let timer = setTimeout(function() {
						uni.reLaunch({
							url: '/pages/index/mine/mine'
						})
						timer = null
					}, 500)
				})

			},
			confirm() {
				this.showoff = false
				this.$api.logout().then(res => {
					console.log(res);
					uni.setStorageSync('Token', res.data.data.token)
					uni.showToast({
						icon: 'success',
						title: '注销成功',
						duration: 2000
					});
					let timer = setTimeout(function() {
						uni.navigateBack()
						timer = null
					}, 1000)
				})
			},
		},
	}
</script>
<style>
	page {
		background-color: #18171D;
	}
</style>
<style lang="scss" scoped>
	@import 'set.scss';
</style>